<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

/**
 * 系统文件列表
 */
class CreateSysFile extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('sys_files', function (Blueprint $table) {
            $table->increments('file_id')->comment('文件自增ID');
            $table->string('disk_name', 20)->default('')->comment('上传磁盘名称');
            $table->string('file_type', 20)->default('')->comment('文件类型');
            $table->string('file_path', 150)->default('')->comment('文件路径,该路径是相对storage\app目录');
            $table->string('view_url', 200)->default('')->comment('访问地址');
            $table->string('origin_name', 150)->default('')->comment('原始文件名');
            $table->string('new_name', 150)->default('')->comment('新文件名');
            $table->string('file_ext', 20)->default('')->comment('文件后缀');
            $table->unsignedInteger('file_size')->default(0)->comment('文件大小，Byte');
            $table->softDeletes();
            $table->timestamps();
            $table->charset = 'utf8';
            $table->collation = 'utf8_unicode_ci';
            $table->index(['view_url','deleted_at'], 'index1');
            $table->index(['file_type','deleted_at'], 'index2');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('sys_files');
    }
}
